<template>
  <el-container>
    <el-header>
      <el-menu mode="horizontal" :ellipsis="false" default-active="0">
        <el-menu-item index="0" @click="open('welcome')">首页</el-menu-item>
        <div class="flex-grow" />
        <el-menu-item index="1">Processing Center</el-menu-item>
        <el-sub-menu index="2">
          <template #title>Workspace</template>
          <el-menu-item index="2-1">item one</el-menu-item>
          <el-menu-item index="2-2">item two</el-menu-item>
          <el-menu-item index="2-3">item three</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-row class="tac">
          <el-col :span="24">
            <el-menu>
              <el-menu-item index="1">
                <el-icon><Location /></el-icon>
                <span @click="open('map')">设备分布</span>
              </el-menu-item>
              <el-menu-item index="2">
                <el-icon><document /></el-icon>
                <span @click="open('dev')">设备管理</span>
              </el-menu-item>
              <el-menu-item index="3">
                <el-icon><PieChart /></el-icon>
                <span @click="open('monitor')">实时监控</span>
              </el-menu-item>
              <el-menu-item index="4">
                <el-icon><setting /></el-icon>
                <span @click="open('control')">反向控制</span>
              </el-menu-item>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-main>
        <!-- 进行路由跳转 -->
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { useRouter } from "vue-router";

export default {
  mounted() {
    const router = useRouter();
    router.push("/welcome");
  },
  setup() {
    const router = useRouter();
    //组合式api不能使用this
    let open = (name) => {
      router.push({ name });
    };
    return { open };
  },
};
</script>

<style scoped>
.el-header {
  background-color: #ffffff;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #ffffff;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #ffffff;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 160px;
}

.el-container {
  height: 100%;
}

.flex-grow {
  flex-grow: 1;
}
</style>
